<div class="layui-layout layui-layout-content">
	<div class="layui-side layui-bg-black">
		<div class="layui-side-scroll">
		<#include "/apps/setting/include/left.html"/></div>
	</div>
	<div class="layui-body">
		<div class="layui-side-scroll">
			<div class="row">
				<div class="col-lg-12">
					<h1 class="site-h1" style="background-color:#FFFFFF;">
						<#if type?? && type=='user'>访客<#else>坐席</#if>敏感词列表<#if sensitivewordList??>（${sensitivewordList.totalElements!''}）</#if>
						<span style="float:right;">
							<button class="layui-btn layui-btn-sm green" href="/setting/sensitive/add.html?type=${type!''}" data-toggle="ajax" data-width="450" data-height="220" data-title="创建">
								创建
							</button>
							<button class="layui-btn layui-btn-sm green" href="/setting/sensitive/batadd.html?type=${type!''}" data-toggle="ajax" data-width="750"  data-title="批量新增敏感词">
								批量创建
							</button>
							<a class="layui-btn layui-btn-sm layui-btn-danger" href="javascript:void(0)" id="batdel" data-toggle="tip" data-title="请确认是否删除勾选的敏感词？">
								批量删除
							</a>
						</span>
					</h1>
					<div class="row" style="padding:5px;">
						<div class="col-lg-12">
							<table class="layui-table" lay-skin="line">
							  <thead>
								<tr>
							      <th>
									  <input type="checkbox" id="all" onclick="$('.ids').prop('checked' , $(this).prop('checked'));"/>
								  </th>
								  <th>敏感词</th>
								  <th style="width: 20%;">词性</th>
								  <th style="width: 20%;">创建时间</th>
								  <th style="width: 1%;"white-space:nowrap;" nowrap="nowrap">操作</th>
								</tr> 
							  </thead>
							  <tbody>
								<#if sensitivewordList?? && sensitivewordList.content??>
								<#list sensitivewordList.content as word>
								<tr>
								  <td style="width:1%;">
									  <input type="checkbox" class="ids" name="ids" value="${word.id!''}"/>
								  </td>
								  <td>
									${word.keyword!''}
								  </td>
								  
								  <td>${word.partofspeech!''}</td>
								  <td><#if word.createtime??>${word.createtime?string("yyyy-MM-dd HH:mm:ss")}</#if></td>
								  <td style="width: 1%;white-space:nowrap;" nowrap="nowrap">
								  		<a href="/setting/sensitive/edit.html?id=${word.id!''}&type=${type!''}" data-toggle="ajax" data-title="编辑敏感词" data-width="450" data-height="220">
								  			<i class="layui-icon">&#xe642;</i>
								  			编辑
								  		</a>
								  		<a href="/setting/sensitive/delete.html?id=${word.id!''}&type=${type!''}" style="margin-left:10px;" data-toggle="tip" data-title="请确认是否删除敏感词？">
								  			<i class="layui-icon" style="color:red;">&#x1006;</i>
								  			删除
								  		</a>
								  </td>
								</tr>
								</#list>
								<#else>
								<tr>
									<td colspan="20" style="height:400px;">
										<div class="ukefu-empty">
											<i class="layui-icon">&#xe63a;</i>
											<div style="">还没有敏感词</div>
										</div>
									</td>
								</tr>
								</#if>
							  </tbody>
							</table>
						</div> 	   
					</div>
					<div class="row" style="padding:5px;">
						<div class="col-lg-12" id="page" style="text-align:center;"></div>
					</div>
				</div>	
			</div>
		</div>
	</div>
</div>

<script>
$(document).ready(function(){
	$('#batdel').click(function(){
		var ids = "";
		$('.ids').each(function(){
			if($(this).prop("checked")){
				if(ids!=""){
					ids += "&" ;
				}
				ids += "ids=" + $(this).val();
			}
		});
		if(ids==""){
			layer.msg('请选择数据！');				
			$('#batdel').attr('href' , 'javascript:void(0)')	;
		}else{
			$('#batdel').attr('href' , '/setting/sensitive/batdel.html?type=${type!''}&'+ids)	;
		}
		
	});
	<#if msg?? &&  msg =="word_exist">
  	top.layer.alert('该敏感词已存在', {icon: 2});
	<#elseif msg?? && msg == 'k_type_exist'>
	top.layer.alert('分类名称重复，请重新填写', {icon: 2});
	</#if>
});	
	layui.use(['laypage', 'layer'], function(){
		  var laypage = layui.laypage
		  ,layer = layui.layer;
		  
		  laypage.render({
				elem: 'page'
				,pages: <#if sensitivewordList??>${sensitivewordList.totalPages}<#else>0</#if> //总页数
				,curr:<#if sensitivewordList??>${sensitivewordList.number+1}<#else>0</#if>
				,groups: 5 //连续显示分页数
				,jump:function(data , first){
					if(!first){
						location.href = "/setting/sensitive/${type!''}/index.html?&p="+data.curr ;
					}
				}
		   });
		  
		});
	
	 
</script>